package com.ruoyi.web.controller.common;


import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;

import java.util.ArrayList;
import java.util.List;

public class WechatMiniProgramPush11 {



    public static void main(String[] args) {
        String appId = "wxe4981a0c2ccb467c";
        String appSecret = "afe0c14d65e622e655d17d37a123863a";
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(appId);
        config.setSecret(appSecret);
        //config.setAccessToken("35_2");

        WxMaService service = new WxMaServiceImpl();
        service.setWxMaConfig(config);

        WxMaSubscribeMessage msg = new WxMaSubscribeMessage();
        msg.setTemplateId("H_o-hpntdGhRWnw6ckW6la_LHQXhf_bQnepej7SzBdo");
        msg.setToUser("o7MmZ5Zjj9OGWOrhikguRQzWgnfQ");
        msg.setMiniprogramState("developer");
        msg.setLang("zh_CN");
        List<WxMaSubscribeMessage.MsgData> data = new ArrayList<>();
        data.add(new WxMaSubscribeMessage.MsgData("thing1", "VALUE1"));
        data.add(new WxMaSubscribeMessage.MsgData("time3", "VALUE1"));
        data.add(new WxMaSubscribeMessage.MsgData("character_string4", "VALUE1"));
        data.add(new WxMaSubscribeMessage.MsgData("amount7", "VALUE1"));
        data.add(new WxMaSubscribeMessage.MsgData("thing8", "VALUE1"));
        msg.setData(data);

        try {
            service.getMsgService().sendSubscribeMsg(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
